// pages/piao/piao.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    piaos:[],
    imgList: [
      "https://qr.api.cli.im/newqr/create?data=https%253A%252F%252Fdevelopers.weixin.qq.com%252Fcommunity%252Fdevelop%252Farticle%252Fdoc%252F000646d83283082e36195ba3156013&level=H&transparent=false&bgcolor=%23ffffff&forecolor=%23000000&blockpixel=12&marginblock=1&logourl=&size=260&logoshape=no&embed_text_fontfamily=simhei.ttc&eye_use_fore=1&qrcode_eyes=null&outcolor=%23000000&incolor=%23000000&body_type=0&qr_rotate=0&text=&fontfamily=simsun.ttc&fontsize=30&fontcolor=%23000000&logo_pos=0&kid=bizcliim&time=1623649577&key=3cb9d430dc1dc2dd8100f9fbab8a6cd2",
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var username=options.username
    var page = this;
    wx.request({
      url: 'http://127.0.0.1:8080/getOrderInfoByUsername_wx',
      method:'GET',
      data:{
        'username': username
      },
      header:{
        "Content-Type":"json"
      },
      success:function(res){
         console.log(res);
         var piaos = new Array();
         var subjects = res.data.data;
         var len = subjects.length >=10?10:subjects.length;
         for(var i=0;i<len;i++){
            var subject = subjects[i];
            var piao = new Object();
            //电影名称
            piao.id = subject.Order_number;
            piao.pay = subject.Actual_money;
            piao.time = subject.Order_time;
            piaos.push(piao);

         }
         console.log(piaos);
         page.setData({piaos:piaos});
      }
    })
  },
  //预览图片，放大预览
  preview(event) {
    console.log(event.currentTarget.dataset.src)
    let currentUrl = event.currentTarget.dataset.src
    wx.previewImage({
      current: currentUrl, // 当前显示图片的http链接
      urls: this.data.imgList // 需要预览的图片http链接列表
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})